package com.gitee.loyo.jdbc

import com.gitee.loyo.Query
import com.gitee.loyo.TUser
import com.gitee.loyo.Update

interface TUserMapper {

    //language=MySQL
    @Query("select * from t_user where instr(user_name, :userName) > 0 and sex = :sex")
    fun queryUsers(userName: String, sex: Int): List<TUser>

    //language=MySQL
    @Query("select user_id, user_name from t_user order by user_id")
    fun queryPairList(): List<Pair<Long, String>>

    //language=MySQL
    @Query("select user_id, user_name, sex from t_user order by user_id")
    fun queryTripleList(): List<Triple<Long, String, Int>>

    //language=MySQL
    @Query("select * from t_user where user_id = :userId")
    fun getUserById(userId: Long): TUser?

    //language=MySQL
    @Query("select user_id, user_name from t_user where user_id = :userId")
    fun getPairById(userId: Long): Pair<Long, String>?

    //language=MySQL
    @Query("select user_id, user_name, sex from t_user where user_id = :userId")
    fun getTripleById(userId: Long): Triple<Long, String, Int>?

    //language=MySQL
    @Update("update t_user set user_name = :user.userName, sex = :user.sex where user_id = :user.userId ")
    fun update(user: TUser): Int
}